﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
using Utilities.QuickSql;

namespace WindowsFormsApplication1
{
    public partial class connexion : Form
    {
        MySqlDatabase db = new MySqlDatabase("localhost", "B2_CS2I", "motdepasse", "projets4");
        public connexion()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button_connex_Click(object sender, EventArgs e)
        {
            Table utilisateur = db.QueryTable("SELECT * FROM utilisateur WHERE nom_user = '" + user_textBox.Text.ToString() + "' AND MDP_user = '" + MDP_textBox.Text.ToString()+"'");
            foreach(Record r in utilisateur)
                if(r.Values[0].ToString() != "")
                    {
                        Administration fenAdmin = new Administration();
                        fenAdmin.Show();
                        this.Close();
                    }       

        }

        private void ajouterUnUtilisateutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Ajout_Utilisateur fenAmin = new Ajout_Utilisateur();
            fenAmin.Show();
        }

        private void MDP_textBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void user_textBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }



    }
}
